		TITLE	CVPACKRN - Copyright (c) SLR Systems 1992

		INCLUDE	MACROS

if	0

		PUBLIC	CVPACK_RUNNER

		.DATA

	SOFT	EXTB	FILNAM,TEMP_RECORD,ASCIZ

	SOFT	EXTW	PSP_SAVER,STARTING_SP,HOST_BASE

		.CODE	ROOT_TEXT

		ASSUME	DS:NOTHING

	SOFT	EXTF	$$SLR_OVL_TERM

if	fgh_dpmi

CMDLINE		EQU	TEMP_RECORD

CVPACK_RUNNER	PROC
		;
		;EVERYTHING IS FINISHED EXCEPT ME...
		;
		FIXDS
		MOV	SP,STARTING_SP		;SO I CAN JUST RETURN TO
		LEA	SI,FILNAM		;DPMI LOADER
		LEA	BX,TEMP_RECORD
		RETF

CVPACK_RUNNER	ENDP

else

CVPACK_RUNNER	PROC
		;
		;THIS NEVER RETURNS...
		;
		FIXDS
		LEA	SI,FILNAM
		PUSH	CS
		POP	ES
		LEA	DI,ASCIZ
		LODSW
		MOV	CX,AX
		REP	MOVSB
		XOR	AX,AX
		STOSW
		LEA	SI,TEMP_RECORD
		LEA	DI,CMDLINE
		LODSW
		STOSB
		MOV	CX,AX
		REP	MOVSB
		MOV	AL,0DH
		STOSB
		CALL	$$SLR_OVL_TERM		;MAKE SURE OVERLAY SYSTEM RELEASED
		MOV	ES,HOST_BASE
		MOV	AH,49H
		INT21
		;
		;SHRINK ME
		;
		MOV	DX,PSP_SAVER
		LEA	BX,MYEND+16
		AND	BX,0FFF0H
		MOV	AX,CS
		MOV	SS,AX			;CHANGE TO NEW STACK
		MOV	SP,BX
		MOV	DS,AX
		ASSUME	SS:@code,DS:@code

		SHRI	BX,4
		ADD	BX,AX			;LAST PARAGRAPH I WANT
		MOV	ES,DX
		ASSUME	ES:NOTHING
		SUB	BX,DX
		MOV	AH,4AH
		INT21
		MOV	AX,SS
		MOV	ES,AX
		ASSUME	ES:@code
		LEA	DX,ASCIZ
		LEA	BX,PARAM_BLOCK
		MOV	AX,4B00H
		INT	21H
		JC	9$
		MOV	AH,4DH
		INT	21H
9$:
		MOV	AH,4CH
		INT	21H

CVPACK_RUNNER	ENDP

PARAM_BLOCK	DW	0
		DD	CMDLINE
		DD	0
		DD	0

		ALIGN	16

CMDLINE		EQU	$

ASCIZ		EQU	CMDLINE+128

MYSTACK		EQU	ASCIZ+256


MYEND		EQU	MYSTACK+512

endif

endif

		END

